// #########################
// ply_values.lua
// For storing temporary player values.
// #########################

// Value st0r4g3.
function GM:InitializePlayerValues()
	self.PlayerValues = {}
end
GM:AddHook("Initialize", "InitializePlayerValues")

// Get the player metatable.
local Player = FindMetaTable( "Player" )
if ( !Player ) then printd( "Player metatable not found!" ) return end

// Player:SetValue( name, value )
// e.g ply:SetValue( "points", 214 )
function Player:SetValue( name, value )
	if !GAMEMODE.PlayerValues then return end
	local values = GAMEMODE.PlayerValues

	local unique = self:UniqueID()
	values[ unique ] = values[ unique ] or {}
	values[ self:UniqueID() ][ name ] = value
end

// Player:GetValue( name, default )
// e.g ply:GetValue( "points", 0 )
// If no value with that name exists, function will return default.
function Player:GetValue( name, default )
	if !GAMEMODE.PlayerValues then return default end
	local values = GAMEMODE.PlayerValues

	local unique = self:UniqueID()
	if ( values[ unique ] && values[ unique ][ name ] ) then
		return values[ unique ][ name ]
	else
		return default
	end
end
